<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SplitContainer Demo</title>
     <style type="text/css">
			@import "../dojo/release4tree/dijit/themes/tundra/tundra.css";
            @import "../dojo/release4tree/dojo/resources/dojo.css";
            @import "../dojo/release4tree/dojox/grid/_grid/tundraGrid.css";
            @import "../dojo/release4tree/dojox/grid/_grid/Grid.css";
            @import "../js/wlProject.css";
			@import "../js/dijitTests.css";
			@import "../dojo/release4tree/dojox/layout/tests/_expando.css";
			@import "../dojo/release4tree/dijit/themes/tundra/tundra.css";
      </style>
      <script type="text/javascript" src="../dojo/release4tree/dojo/dojo.js"  
                djConfig="parseOnLoad: true, isDebug: true,locale: 'zh-cn', extraLocale: ['zh-TW', 'fr']"></script>
      <script>
    
            dojo.require("dojo.data.ItemFileWriteStore");
			dojo.require("dijit.layout.TabContainer");
			dojo.require("dijit.layout.AccordionContainer");
			dojo.require("dijit.layout.BorderContainer");
            dojo.require("dojox.layout.ExpandoPane");
            dojo.require("dijit.layout.ContentPane");
            dojo.require("dijit.Tree");
            dojo.require("dojo.parser");
            dojo.require("dijit._tree.dndSource");
            dojo.require("dijit.layout.TabContainer");
            dojo.require("dijit.form.Button");
            dojo.require("dojox.grid.Grid");
            dojo.require("dojox.grid._data.model");
            dojo.require("dojo.i18n");
            dojo.require("dojox.validate._base");
            dojo.require("dijit.form.ValidationTextBox");
            dojo.require("dijit.form.TextBox");
            dojo.require("dijit.form.FilteringSelect");
            dojo.require("dojox.grid._data.dijitEditors");
            
            dojo.registerModulePath("mydojo", "../../../js/mydojo");
            dojo.require("mydojo.FilteringSelect");
            dojo.require("mydojo.ValidationTextBox");
            
     </script>
        
    <script type="text/javascript" src="../js/soapclient.js"></script>
    <script type="text/javascript" src="../js/wlProject.js"></script>
	<script type="text/javascript" src="../js/peoplevo.js"></script>
	<script type="text/javascript" src="../js/orgavo.js"></script>
	<script type="text/javascript" src="../js/orgaPeoplevo.js"></script>
	<script type="text/javascript" src="../js/peopleRolevo.js"></script>
	<script type="text/javascript" src="../js/rolevo.js"></script>
    <script type="text/javascript" >

//@import "../dojo/release4tree/dijit/themes/tundra/tundra.css";
            
        var url = getUrl()+ "services/OrgaPeopleManageService";
        var data =new Array();
        var poptarts ={ label:'name',identifier:'eId',items:data};
        var popStore = new dojo.data.ItemFileWriteStore({data: poptarts});
		 
        var orderBy='0';
        var deletedata2 =new Array();
          //var itemt="区域";
        var selectNodeIdentity=0;//单击的树节点ID
        var selectNode;
          
		var griddata =  new Array();
		var deletedata=new Array();
		var querydata =  new Array();
		var queryvo=new PeopleVO(); //   
		var totalCount=0 ;
		var totalpage=0 ;
		var pagenumber=1;
		var pagesize=10;
		var model = new dojox.grid.data.Table(null, griddata);
		var handleTreeModel1 = new dijit.tree.ForestStoreModel({
  				store: popStore,
  				rootId: "handleRoot",
  				rootLabel: "系统操作",
  				childrenAttrs: ["children"]
  			}); 
		   var editfield =[{type: 'dojox.GridRowView', width: '20px' },{
          
                 //?ù??field???????????????????ò????js????toArray×???·?·¨·?????querydate????????
                       
                                 cells: [ [
                                            //{name: '????', width: 3, get:getChoise},
                                           { name: 'choise', width: 3,field:0, styles: 'text-align: center;', editor: dojox.grid.editors.Bool },//
                                           { name: 'No.', width: 2, styles: 'text-align: center;', get: function(inRowIndex){ return inRowIndex+1;} },//
                                          {name: 'peopleName', field: 2,width: 10 , editor: mydojo.ValidationTextBox ,required:true ,maxLength:30,invalidMessage:'can not be empty'}
                                             ,   {name: 'peoplePassword', field: 3,width: 10 , editor: mydojo.ValidationTextBox ,required:true ,maxLength:30,invalidMessage:'can not be empty'}
                                             ,   {name: 'remark', field: 4,width: 10, editor: mydojo.ValidationTextBox , required:false ,maxLength:100,invalidMessage:'' }
                                             ,   {name: 'peopleStatus', field: 5,width: 10 , editor: mydojo.ValidationTextBox ,required:true ,maxLength:30,invalidMessage:'can not be empty'}
                                         ,   {name: 'birthDay',field:6, width: 8,editor: dojox.grid.editors.DateTextBox,  formatter: formatDate,  constraint: { selector: "date",datePattern: "yyyy-MM-dd"}}
                                     //,   {name: 'birthDayTime',field:7, width: 8,editor: dojox.grid.editors.TimeTextBox, formatter: formatDate, constraint: {selector: "time" ,timePattern: "HH:mm"}}
                                         ,   {name: 'sex', field: 8,width: 10 , editor: mydojo.ValidationTextBox ,required:true ,maxLength:30,invalidMessage:'can not be empty'}
                                             ,   {name: 'birthPlace', field: 9,width: 10, editor: mydojo.ValidationTextBox , required:false ,maxLength:100,invalidMessage:'' }
                                             ,   {name: 'address', field: 10,width: 10, editor: mydojo.ValidationTextBox , required:false ,maxLength:100,invalidMessage:'' }
                                             ,   {name: 'tel', field: 11,width: 10, editor: mydojo.ValidationTextBox , required:false ,maxLength:100,invalidMessage:'' }
                                             ,   {name: 'engageMode', field: 12,width: 10, editor: mydojo.ValidationTextBox , required:false ,maxLength:100,invalidMessage:'' }
                                         ,   {name: 'engageDate',field:13, width: 8,editor: dojox.grid.editors.DateTextBox,  formatter: formatDate,  constraint: { selector: "date",datePattern: "yyyy-MM-dd"}}
                                    // ,   {name: 'engageDateTime',field:14, width: 8,editor: dojox.grid.editors.TimeTextBox, formatter: formatDate, constraint: {selector: "time" ,timePattern: "HH:mm"}}
                                         ,   {name: 'grade', field: 15,width: 10, editor: mydojo.ValidationTextBox , required:false ,maxLength:100,invalidMessage:'' }
                                             ] ]
                           }];

function call_funUpd() {
       //var s = grid.selection.getSelected();
       var  d=new DateTimeQuery();
       var n=new NumberQuery();
       var sall=grid.model.data;
       for(var i=0;i<sall.length;i++){
       if(sall[i][0]==true){
         var passAll=0;
         var thisCell=sall[i];
         var padd = new SOAPClientParameters2();
         var vobject=new PeopleVO();
         vobject.id=thisCell[1];
              if(dojox.validate.isText(thisCell[2], {minlength: 1})){vobject.peopleName=thisCell[2];
             }else{grid.getCell(2).getNode(i).innerHTML="<span style={color:red;line-height:16px}>can not be null</span>"; passAll=1;}//not null
               if(dojox.validate.isText(thisCell[3], {minlength: 1})){vobject.peoplePassword=thisCell[3];
             }else{grid.getCell(3).getNode(i).innerHTML="<span style={color:red;line-height:16px}>can not be null</span>"; passAll=1;}//not null
                vobject.remark=thisCell[4];
               if(dojox.validate.isText(thisCell[5], {minlength: 1})){vobject.peopleStatus=thisCell[5];
             }else{grid.getCell(5).getNode(i).innerHTML="<span style={color:red;line-height:16px}>can not be null</span>"; passAll=1;}//not null
              if(thisCell[6] instanceof Date){
			  d.upDate=dojo.date.locale.format(thisCell[6], {timePattern: "HH:mm",datePattern: "yyyy-MM-dd"});
			  vobject.birthDay=d;
             }else{grid.getCell(6).getNode(i).innerHTML="<span style={color:red;line-height:16px}>must be date</span>"; passAll=1;}//not null
               if(dojox.validate.isText(thisCell[8], {minlength: 1})){vobject.sex=thisCell[8];
             }else{grid.getCell(8).getNode(i).innerHTML="<span style={color:red;line-height:16px}>can not be null</span>"; passAll=1;}//not null
                vobject.birthPlace=thisCell[9];
                vobject.address=thisCell[10];
                vobject.tel=thisCell[11];
                vobject.engageMode=thisCell[12];
              if(thisCell[13] instanceof Date){d=new DateTimeQuery();
			  d.upDate=dojo.date.locale.format(thisCell[13], {timePattern: "HH:mm",datePattern: "yyyy-MM-dd"});
			  vobject.engageDate=d;
             }else{grid.getCell(13).getNode(i).innerHTML="<span style={color:red;line-height:16px}>must be date</span>"; passAll=1;}//not null
               vobject.grade=thisCell[15];
        if(passAll==0){
             if(thisCell[1]==0){//create new row
                padd.add('peopleVO',vobject);
                padd.add('orgaId',selectNodeIdentity);
                SOAPClient.invoke(url, "createPeopleAndOrgapeo", padd, false,  function GetEnu_callBack(ul, soapResponse){
                grid.model.setDatum(ul,i,1);
				//addTreeNode(selectNode,vobject.peopleName,selectNodeIdentity+"peo"+ul)
				addTreeNode(selectNode.item,vobject.peopleName,ul);
                });
	         }else{//modify row
                padd.add('PeopleVO',vobject);
                SOAPClient.invoke(url, "updatePeople", padd, false,  function GetEnu_callBack(ul, soapResponse){
				setTreeNode(vobject.id,vobject.peopleName)
                });
	         }
        } }}//for
//submit delete
          for(var i=0;i<deletedata.length;i++){
               var pdel = new SOAPClientParameters();      
               pdel.add('id',deletedata[i]);
               SOAPClient.invoke(url, "deletePeopleAndOrgapeo", pdel, false,  function GetEnu_callBack(ul, soapResponse){
	             delTreeNode(deletedata[i]);
	           });
          }
          deletedata=new Array();
          dojo.byId("rowCount").innerHTML = 'saved'; 
//submit delete end          
 }

 function removeSelectedRowsGrid(){
       //var s = grid.selection.getSelected();
       var s= new Array();
       var sall=grid.model.data;
       for(var i=0;i<sall.length;i++){
       if(sall[i][0]==true){
          s.push(i);
          var thisCell=sall[i];
          if(thisCell[1]!=0){//the row which will be deleted
            deletedata.splice(deletedata.length,0,thisCell[1]);
       }}}
      grid.model.remove(s);//grid.removeSelectedRows();
 }

   function addTreeNode(pid,peopleName,id){
				var pInfo = {
								parent: pid,		
								attribute: "children"	
							};
               popStore.newItem({name: peopleName,eId:"peo"+id}, pInfo);
         }  
	function delTreeNode(id){
		var node = dijit.byId("tree")._itemNodeMap["peo"+id];
		popStore.deleteItem(node.item);//同时删除所有子节点
	  }  
	  
	function setTreeNode(id,peopleName){
		var node = dijit.byId("tree")._itemNodeMap["peo"+id];
		//alert("placeName:"+placeName);
		//alert("placeType:"+placeType);
		popStore.setValue(node.item,"name",peopleName);         
		node.setLabelNode(peopleName);
		 }  
addRow = function(){
          	grid.addRow([false,0,"","","","",""],grid.model.getRowCount());
	        } 
                          
function querybutton(){
              //var p = new SOAPClientParameters2();
              var d,n;
              var validstate=0;
              //queryvo.id=0 ;
              queryvo=new PeopleVOJs();
              if(querypeopleName.getDisplayedValue()!="")queryvo.peopleName=querypeopleName.getDisplayedValue();//
              if(querypeoplePassword.getDisplayedValue()!="")queryvo.peoplePassword=querypeoplePassword.getDisplayedValue();//
              if(queryremark.getDisplayedValue()!="")queryvo.remark=queryremark.getDisplayedValue();//
              if(querypeopleStatus.getDisplayedValue()!="")queryvo.peopleStatus=querypeopleStatus.getDisplayedValue();//
              d=queryDate_fun("birthDay");
              if(d==null){validstate=1;}else if(d.upSign!="%"){queryvo.birthDay=d;}
              if(querysex.getDisplayedValue()!="")queryvo.sex=querysex.getDisplayedValue();//
              if(querybirthPlace.getDisplayedValue()!="")queryvo.birthPlace=querybirthPlace.getDisplayedValue();//
              if(queryaddress.getDisplayedValue()!="")queryvo.address=queryaddress.getDisplayedValue();//
              if(querytel.getDisplayedValue()!="")queryvo.tel=querytel.getDisplayedValue();//
              if(queryengageMode.getDisplayedValue()!="")queryvo.engageMode=queryengageMode.getDisplayedValue();//
              d=queryDate_fun("engageDate");
              if(d==null){validstate=1;}else if(d.upSign!="%"){queryvo.engageDate=d;}
              if(querygrade.getDisplayedValue()!="")queryvo.grade=querygrade.getDisplayedValue();//
        if(validstate==0){
              pagenumber=1;
              getVO(queryvo,pagenumber,pagesize,'0');
              if(totalpage>1){dijit.byId("but7").setDisabled(false);}else{dijit.byId("but7").setDisabled(true);}
             }      
       }

 querydis = function(){
               querydisplay("queryDiv");
            }
 
 


function getPeopleVO(queryvo,pagenumber,pagesize,orderBy){

      var pu = new SOAPClientParameters2();
      pu.add('PeopleVO',queryvo) ;
      pu.add('pageNumber',pagenumber) ;
	    pu.add('pageSize',pagesize) ;
	    pu.add('orderBy',orderBy) ;
      SOAPClient.invoke(url,"getPeople", pu, false,  function GetEnu_callBack(ul, soapResponse){      
           querydata=PeopleVOtoArray_fun(ul,true);
           totalCount=ul[ul.length-1]["ns:id"]; 
           totalpage=Math.ceil(new Number(totalCount)/pagesize);
           document.getElementById("rowCount").innerHTML=" "+pagenumber+" / "+totalpage+" / "+totalCount+" " ;
      }); 
      //querydata.splice(querydata.length-1,1);
      //model.setData(querydata);
      //dijit.byId("grid").updateRowCount(querydata.length); 
 }
 
 


function getOrgaVO(queryvo,pagenumber,pagesize,orderBy){

      var pu = new SOAPClientParameters2();
      pu.add('OrgaInfoVO',queryvo) ;
      pu.add('pageNumber',pagenumber) ;
	    pu.add('pageSize',pagesize) ;
	    pu.add('orderBy',orderBy) ;
      SOAPClient.invoke(url,"getOrgaInfo", pu, false,  function GetEnu_callBack(ul, soapResponse){      
           querydata=OrgaInfoVOtoArray_fun(ul,true);
           totalCount=ul[ul.length-1]["ns:id"]; 
           totalpage=Math.ceil(new Number(totalCount)/pagesize);
           document.getElementById("rowCount").innerHTML=" "+pagenumber+" / "+totalpage+" / "+totalCount+" " ;
      }); 
      querydata.splice(querydata.length-1,1);
      model.setData(querydata);
      //dijit.byId("grid").updateRowCount(querydata.length); 
 }
          
        
        
  var myModel = new dijit.tree.ForestStoreModel({
  				store: popStore,
  				rootId: "0",
  				rootLabel: "部门",
  				childrenAttrs: ["children"]
  			});        
  var _tree=dijit.byId("tree");      
  function getTreeNodes(orgaSno,chitem,layerInt,layerSum){//首层layerInt=0
  //获得机构
           var pl = new SOAPClientParameters();
           pl.add('orgaSno',orgaSno) ;
           pl.add('orgaName','%') ;
           pl.add('orgaCode','%') ;
           pl.add('remark','%') ;
           pl.add('orgaState','%') ;
           pl.add('id',0) ;
		    var pInfo = {
                   					parent: chitem,		
                   					attribute: "children"	
                   		};
           SOAPClient.invoke(url, "getOrgaInfoVO", pl, false,  function GetEnu_callBack(ul, soapResponse){
               if(ul!=null && ul.length>0 ){
                     for(var i = 0; i < ul.length; i++){		
                                  var ulo=ul[i];
                                  var newitem=popStore.newItem({name: ulo["ns:orgaName"],type:ulo["ns:orgaSno"] ,eId:ulo["ns:id"],haveChild:'0'}, pInfo);//haveChild=0初始，1有子结点，2无子结点，3people
                                  if(layerInt<layerSum)getTreeNodes(ulo["ns:orgaSno"]+"___",newitem,layerInt+1,layerSum);
                              }
                      if(chitem!=null){
                            popStore.setValue(chitem,"haveChild","1"); 
                            var node = dijit.byId("tree")._itemNodeMap[chitem.eId];
                            node._updateItemClasses(node.item);
                            //node.expand();       
                      }
                }else{
                    popStore.setValue(chitem,"haveChild","2");  
                }       
          });
	//获得人员叶
			var pu = new SOAPClientParameters2();
			var OrgaPeoplequeryvo=new OrgaPeopleVOJs();
			var orgaquervo= new OrgaInfoVOJs();
			if(chitem!=null){
			orgaquervo.id=chitem["eId"];
			OrgaPeoplequeryvo.orga=orgaquervo;
			var pu = new SOAPClientParameters2();
	        pu.add('OrgaPeopleVO',OrgaPeoplequeryvo) ;
	        pu.add('pageNumber',0) ;
		    pu.add('pageSize',0) ;
		    pu.add('orderBy','0') ;
	      SOAPClient.invoke(url,"getOrgaPeople", pu, false,  function GetEnu_callBack(ul, soapResponse){      
	           var querydataOrgaPeople=OrgaPeopleVOtoArray_fun(ul,false);
	           var peoplequerydate =new Array();
			for(var i=0;i<querydataOrgaPeople.length-1;i++){
				var ulo=querydataOrgaPeople[i][2];
				//alert(ulo["ns:peopleName"]);
				//alert("querydataOrgaPeople[i][2]:"+querydataOrgaPeople[i][2]);
				popStore.newItem({name: ulo["ns:peopleName"],type:ulo["ns:id"] ,eId:"peo"+ulo["ns:id"],haveChild:'3'}, pInfo);//haveChild=0初始，1有子结点，2无子结点，3people
			}
      }); }
		   // var node = dijit.byId("tree")._itemNodeMap[chitem.eId];
            //           node._updateItemClasses(node.item);	
   }
   function expandAllChildrenNode(tree,treeNode,layerInt,layerSum){
		       var childrenArray=treeNode.getChildren();
          if(childrenArray!=null&&childrenArray.length>0)tree._expandNode(treeNode);
         
          
          for (var i=0; i<childrenArray.length; i++){	
             if(layerInt<layerSum) expandAllChildrenNode(tree,childrenArray[i],layerInt+1,layerSum);
             if(layerInt==layerSum)childrenArray[i]._updateItemClasses(childrenArray[i].item);
          }
        }              
        
function getOrgaPeopleVO(queryvo,pagenumber,pagesize,orderBy){

        var pu = new SOAPClientParameters2();
        pu.add('OrgaPeopleVO',queryvo) ;
        pu.add('pageNumber',pagenumber) ;
	    pu.add('pageSize',pagesize) ;
	    pu.add('orderBy',orderBy) ;
      SOAPClient.invoke(url,"getOrgaPeople", pu, false,  function GetEnu_callBack(ul, soapResponse){      
           querydata=OrgaPeopleVOtoArray_fun(ul,false);
           totalCount=ul[ul.length-1]["ns:id"]; 
           totalpage=Math.ceil(new Number(totalCount)/pagesize);
           document.getElementById("rowCount").innerHTML=" "+pagenumber+" / "+totalpage+" / "+totalCount+" " ;
      }); 
      //querydata.splice(querydata.length-1,1);
      var peoplequerydate =new Array();
      for(var i=0;i<querydata.length-1;i++){
        peoplequerydate[i]=PeopleVOtoArray_fun(querydata[i][2],true);
      }
      //alert(peoplequerydate);
      model.setData(peoplequerydate);
      //dijit.byId("grid").updateRowCount(querydata.length); 
 }
 
 function getPeopleRoleVO(queryvo,pagenumber,pagesize,orderBy){
	  var reData=new Array();
      var pu = new SOAPClientParameters2();
      pu.add('PeopleRoleVO',queryvo) ;
      pu.add('pageNumber',pagenumber) ;
	    pu.add('pageSize',pagesize) ;
	    pu.add('orderBy',orderBy) ;
      SOAPClient.invoke(getUrl()+ "services/OrgaPeopleManageService","getPeopleRole", pu, false,  function GetEnu_callBack(ul, soapResponse){      
           reData=PeopleRoleVOtoArray_fun(ul,false);
      }); 
      reData.splice(reData.length-1,1);
	  return reData;
      //model.setData(querydata);
      //dijit.byId("grid").updateRowCount(querydata.length); 
 }  
 var roleOpid=new Array();
 function getRoleVO(queryvo,pagenumber,pagesize,orderBy){
	  var reData=new Array();
      var pu = new SOAPClientParameters2();
      pu.add('RoleInfoVO',queryvo) ;
      pu.add('pageNumber',pagenumber) ;
	    pu.add('pageSize',pagesize) ;
	    pu.add('orderBy',orderBy) ;
      SOAPClient.invoke(getUrl()+ "services/RoleHandleManageService","getRoleInfo", pu, false,  function GetEnu_callBack(ul, soapResponse){      
           reData=RoleInfoVOtoArray_fun(ul,false);
           }); 
      reData.splice(reData.length-1,1);
      return reData;
 }

 function addPeopleRoleVO(vobject){
				var id;
				var padd = new SOAPClientParameters2();  
				padd.add('PeopleRoleVO',vobject);
                SOAPClient.invoke(getUrl()+ "services/OrgaPeopleManageService", "createPeopleRole", padd, false,  function GetEnu_callBack(ul, soapResponse){
					id=ul;});
				return id;
				}
 function delPeopleRoleVO(id){
			   var pdel = new SOAPClientParameters();      
               pdel.add('id',id);
               SOAPClient.invoke(getUrl()+ "services/OrgaPeopleManageService", "deletePeopleRole", pdel, false,  function GetEnu_callBack(ul, soapResponse){
	             
	           });
 }
 function save_peoRole(){
					var selRole=document.getElementById("selectRole");
					for(var j=0;j<selRole.length;j++){
						if(selRole.options[j].selected==true){
							var isAdd=true;
							for(var i=0;i<roleOpid.length;i++){
								if(roleOpid[i][1]==selRole.options[j].value){
									isAdd=false;
									i=roleOpid.length;
								}
							}	
							if(isAdd==true){
								var peopleRolevo=new PeopleRoleVOJs();
								var peovo=new PeopleVO(); peovo.id=selectNode.item["type"]; peopleRolevo.people=peovo;
								var rolevo=new RoleInfoVOJs();rolevo.id=selRole.options[j].value;peopleRolevo.role=rolevo;
								var addPeopleRoleID=addPeopleRoleVO(peopleRolevo);
								roleOpid[roleOpid.length]=[addPeopleRoleID,selRole.options[j].value];
							}
						}else if(selRole.options[j].selected==false){
							var isDel=false;delIndex=0;
							for(var i=0;i<roleOpid.length;i++){
								if(roleOpid[i][1]==selRole.options[j].value){
									isDel=true;	delIndex=i;
									i=roleOpid.length;
								}
							}
							if(isDel==true){
								delPeopleRoleVO(roleOpid[delIndex][0]);
								roleOpid.splice(delIndex,1);
								}		
						}
					}
}
 function reset_peoRole(){
			if(roleOpid.length!=0){
				var selRole=document.getElementById("selectRole");
				for (var i = 0; i < roleOpid.length; i++) {
						for(var j=0;j<selRole.length;j++){
							if(selRole.options[j].value==roleOpid[i][1]){
								selRole.options[j].selected=true;
								j=selRole.length;
							}
				}}}}

 function selRoleCha(){
 
 
 }				
function optionOnclick(){
//alert(this.selected);
}				
				
   function init(){
        //添加分类第一层结点        
		    var _tree=dijit.byId("tree");  
		    getTreeNodes("___",null,0,2);//001,002,003...
		    expandAllChildrenNode(_tree,_tree.rootNode,0,1);

		dojo.connect(dijit.byId("tree"), "_onExpandoClick", function(message){
                       var node = message.node;
					   //alert("node.item.haveChild:"+node.item.haveChild);
					   if(node.item.haveChild=="1"&&node.item.haveChild!="3"){
                       var ch2node=node.getChildren();
                       for (var i=0; i<ch2node.length; i++){	
                       if(ch2node[i].getChildren().length==0&&ch2node[i].item.haveChild=="0"){
                         var ch2item =ch2node[i].item;
                         getTreeNodes(ch2item.type+"___",ch2item,0,1);
                       }}}
            });   
	//初始化角色多选框		
			var rolequeryvo=new RoleInfoVOJs();
			var roleDate=new Array();
			var aOption;
			roleDate=getRoleVO(rolequeryvo,pagenumber,pagesize,orderBy);
			var selRole=document.getElementById("selectRole");
			for (var i = 0; i < roleDate.length; i++) {
				var roleOp=roleDate[i];
					aOption = document.createElement("OPTION");     		
					aOption.text=roleOp[2];
					aOption.value=roleOp[1];  
					aOption.onclick=optionOnclick;
				selRole.add(aOption,null); 	
			}
					 
//查询列表----begin

    dojo.connect(_tree, "onClick", function(item,node){
             //判断哪个tab在显示
             	    selectNode=node;
                    selectNodeIdentity = _tree.store.getIdentity(item);
                    //var p0 = new SOAPClientParameters();
			//if(node.item.haveChild=="1"&&node.item.haveChild!="3"){		
              if(node.item.haveChild=="3"){
                    var peopleRolequeryvo=new PeopleRoleVOJs();
                    var peoquervo= new PeopleVO();
					var roleDate=new Array();
					roleOpid=new Array();
					var aOption;
                    peoquervo.id=item["type"];
                    peopleRolequeryvo.people=peoquervo;
                    roleDate=getPeopleRoleVO(peopleRolequeryvo,pagenumber,pagesize,orderBy);
					var selRole=document.getElementById("selectRole");
					/*for(var j=0;j<selRole.length;j++){
						selRole.options[j].selected=false;
					}*/
					selRole.selectedIndex=-1;
					for (var i = 0; i < roleDate.length; i++) {
						var roleOp=RoleInfoVOtoArray_fun(roleDate[i][2],false);
						roleOpid[i]=[roleDate[i][1],roleOp[1]];//[peopleRoleId , roleID]
						for(var j=0;j<selRole.length;j++){
							if(selRole.options[j].value==roleOp[1]){
								selRole.options[j].selected=true;
								j=selRole.length;
							}
					}}
					
                /* var titles=node.item["name"];
                var parentNodes=node;
                while(parentNodes.getParent()!= null&& parentNodes.getParent()["id"]!="tree"){
                      parentNodes=parentNodes.getParent();
                      titles=parentNodes.item["name"]+' '+titles;
                };
                dojo.byId("placetitle").innerHTML = titles +"";*/
             }else if(node.item.haveChild!="3"){
                    //var orgaquervo= new OrgaInfoVOJs();
					
                   /* queryvo.orgaSno=item['type']+"___";
					if(item['type']==undefined)queryvo.orgaSno="___";
                    getOrgaVO(queryvo,pagenumber,pagesize,orderBy);
                    
                grid.selection.clear();
				deletedata =new Array();*/
              }
          });  
           //查询列表----end
  }//END INIT
            
           dojo.addOnLoad(init);
           

          //查询按钮
          
          

             
</script>
</head>
<body class="tundra">
	<div dojoType="dijit.layout.TabContainer" style="height:100%; width:100%;" tabPosition="left-h">
	<div dojoType="dijit.layout.ContentPane" title="人<br>员<br>权<br>限<br>分<br>配<br>&nbsp;|<br>人<br>员<br>查<br>询">
		<div  dojoType="dijit.layout.BorderContainer" style="height:100%; width:100%;" >
			<div dojoType="dojox.layout.ExpandoPane" splitter="true" duration="125" region="left"   maxWidth="275" style="width: 275px; background: #fafafa;"id="peopleTreePane" title="">
				<div id="tree"  attachParent="true"  showRoot="true" persist="false" dojoType="dijit.Tree"  store="popStore" labelAttr="name"  childrenAttr="children"  model="myModel" ></div>		
			</div>
		
			<div dojoType="dijit.layout.ContentPane" region="center"  id="peoplePane"  title="选择人员角色">
				<br><br>
				<table align="center" width="80%" class="queryTable"  >
					<tr style="{height:10px}"><td ></td><td ></td></tr >
	                <tr ><td align="center" style="{width:30%}">
						<select align="center" size="26"  id="selectRole" style="width:200;height:750" onchange="selRoleCha()" MULTIPLE></select></td>
	                <td align="right"  style="{width:20%}" ></td>
					<td align="left" valign="top" style="{width:50%}" ><br><br><br><br>
						<div id="handleTree1"  showRoot="true" persist="false" dojoType="dijit.Tree"   labelAttr="name"  model="handleTreeModel1" ></div>
					</td></tr >
					<tr ><td align="center" style="{width:30%}">
						<button dojoType="dijit.form.Button" id="butsave" jsId="butsave" onclick="save_peoRole();"  iconClass="saveIcon">save</button>
						<button dojoType="dijit.form.Button" id="butreset" jsId="butreset" onclick="reset_peoRole();"  iconClass="saveIcon">reset</button></td>
	                <td align="center"  style="{width:20%}" ></td>
					<td align="center"  style="{width:50%}" ></td>
					</tr >
				</table>
		    </div>
		</div>
	</div>

		<div dojoType="dijit.layout.ContentPane"  title="人<br>员<br>权<br>限<br>分<br>配<br>&nbsp;|<br>角<br>色<br>查<br>询">
		</div>
		<div dojoType="dijit.layout.ContentPane" href="roleHandle3.html" refreshOnShow="true" title="角<br>色<br>权<br>限<br>分<br>配<br>&nbsp;|<br>角<br>色<br>查<br>询">
		</div>
		<div dojoType="dijit.layout.ContentPane" title="角<br>色<br>权<br>限<br>分<br>配<br>&nbsp;|<br>操<br>作<br>查<br>询">
		</div>
	</div>
</body></html>
